.so ../bk-macros
.TH "bk initscripts" "\*[BKVER]" %E% "\*(BC" "\*(UM"
.SH NAME
bk initscripts \- sample script for starting the \*(BK daemon
.SH EXAMPLES
.DS 0
#!/bin/sh
#
# bitkeeper	Start/stop the bitkeeper daemon.
# 		@(#)bitkeeper.init 1.1 Copyright (c) 2000 Larry McVoy
#
# When starting repositories that are bound 
# to a specific port, create a file named
# /var/bitkeeper/repositories. The repositories 
# file will contain a line for each repository.
# The line consists of the directory where the
# repository resides and a set of options used 
# when started the bk daemon.
#
# For example:
#
# ---- cut here and remove the leading hash mark and spaces -----
# /home/bk/LMbench -p5000 -xcd -xpush -u99
# /home/bk/bitcluster -p6000 -xcd -xpush -u99
# /home/bk/one -p7000 -xcd -xpush -u99
# --------------------- cut here ----------------------

# Source networking configuration.
if [ -f /etc/sysconfig/network ]
then	. /etc/sysconfig/network

	# Check that networking is up.
	[ ${NETWORKING} = "no" ] && exit 0
fi
[ -x /usr/bin/bk ] || exit 0
VAR=/var/bitkeeper

case "$1" in
    start_msg)	echo "Start BitKeeper daemons"
		;;
    stop_msg)	echo "Stop BitKeeper daemons"
		;;
    restart)	$0 stop
		$0 start
		;;
    start)	cd $VAR || exit 1
		test -f repositories || {
			echo Nothing advertised: Are there any entries in the
			echo $VAR/repositories file?
			exit 0
		}
		while read dir opts
		do	(
			cd $dir || exit 1
			F=\`basename $dir\`
			bk bkd $opts -l$VAR/log.$F -P$VAR/pid.$F
			echo Started bkd $opts in $dir
			)
		done < repositories
		;;

    stop)	
		cd $VAR || exit 1
		echo Shutting down BitKeeper daemons
		for i in pid.*
		do	kill -TERM \`cat $i\`
			rm $i
		done
		;;

    status)	ps -axf | grep bkd
		;;

    *)		echo "Usage: bitkeeper {start|stop|restart|status}"
		exit 1
		;;
esac
exit 0
.DE
.\" help://Admin/init.d
.SH CATEGORY
.B Overview
.br
.B Admin
